﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kortex.Common;
using System.Windows.Forms;

using System.Collections;
using System.Drawing;
using Kortex.Communication_objs;

namespace Kortex.Container
{


    public class input_record
    {
        

        public input_record(int col,int row, string input_p)
        {
            pos_col = col;
            pos_row = row;
            input = input_p;
            
        }

        public int pos_col;
        public int pos_row;
        public string input;

    }

    public class Recorders_record
    {
        public Cube_command_reqObj req;
        public General_responce res;
        public DateTime Time = DateTime.Now;
        public bool isDuplicate = false;

        public Recorders_record(Cube_command_reqObj req_p, General_responce res_p)
        {
            req = req_p;
            res = res_p;
        }
    
    }

    public enum reqResType
    {
        type_req,
        type_res,
        type_none
    
    }

    public class ReqRespDebugInfo
    {
        public ReqRespDebugInfo(string json,reqResType type)
        {
            mJson = json;
            cmd_type = type;
        }

        public string mJson;
        public string mIp = string.Empty;
        public int mCol;
        public int mRow;
        public DateTime Time = DateTime.Now;
        public reqResType cmd_type = reqResType.type_none;
    
    }

    public class GuiBoxArray
    {

        public void clearAll()
        {
           foreach (TextBox arg in TextBoxArray)
           {
               arg.Clear();
               arg.BackColor = Color.White;

           }

           foreach (ComboBox arg in ComboArray)
           {
               arg.Text = "";
               arg.BackColor = Color.White;

           }
        
        }

        public TextBox[] Add(params TextBox[] arg_p)
        {
            Int32 i = mNumObj;
            TextBoxArray = new TextBox[arg_p.Length];
            TextArray = new ArrayList();
            foreach (TextBox arg in arg_p)
            {
                TextBoxArray[i] = arg;
                TextArray.Add(arg);
                mNumObj++;
                i++;
            }
            return TextBoxArray;
        }

        public ComboBox[] Add(params ComboBox[] arg_p)
        {
            Int32 i = mNumObj;
            ComboBoxArray = new ComboBox[arg_p.Length];
            ComboArray = new ArrayList();
            foreach (ComboBox arg in arg_p)
            {
                ComboBoxArray[i] = arg;
                ComboArray.Add(arg);
                mNumObj++;
                i++;
            }
            return ComboBoxArray;
        }

        public ArrayList TextBoxArrayList
        {
            get
            {
                return TextArray;
            }
        }

        public TextBox[] TextBoxs
        {
            get
            {
                return TextBoxArray;
            }
        }

        public ComboBox[] ComboBoxs
        {
            get
            {
                return ComboBoxArray;
            }
        }


        public TextBox[] TextBoxArray = null;
        public ComboBox[] ComboBoxArray = null;
        public Int32 mNumObj = 0;
        public ArrayList TextArray;
        public ArrayList ComboArray;
        public RichTextBox RBox;
        public Label mLabel;
    }

    public enum cmd_requster
    {
        none,
        cubeControler,
        cubeControler_rpc_mode,
        wallControler,
        wallmanagerself,
        nslcubeself,
        recoderControler,
        
    }
    public class Cube_command_Serlizer_obj
    {

        public Cube_command_Serlizer_obj()
        { 
        
        }
        public Cube_command_Serlizer_obj(Cube_command_reqObj obj)
        {
            //mIp = obj.mIp;
            //mRow =obj.mRow;
            //mCol = obj.mCol;
            cmdType = obj.cmdType;

            if (obj.args != null)
            {
                args = new string[obj.args.Length];

                for (int i = 0; i < obj.args.Length; i++)
                    args[i] = obj.args[i];
            }

        
        }
        public commandType cmdType = commandType.cmd_none;
        public string[] args = null;
        //public string mIp = string.Empty;
        //public int mRow, mCol;
        public string version = "0.1";

    
    }

    public class Cube_command_reqObj
    {
        public commandType cmdType = commandType.cmd_none;
        public string[] args = null;
        public int ident;
        public int mRow, mCol;
        public string mIp = string.Empty;
        public string mSerialNum = string.Empty;
        public GuiBoxArray guiVal = null;
        public DateTime Req_time = DateTime.Now;
        public TextBox ReturnBox = null;
        public cmd_requster requester_guy = cmd_requster.none;
        public string rpcPollId = string.Empty;
        public Int32 MsgCount;
        public Int32 linenum;

        public Cube_command_reqObj(Cube_command_Serlizer_obj obj)
        {
            cmdType = obj.cmdType;

            if (obj.args != null)
            {
                args = new string[obj.args.Length];
                for (int i = 0; i < obj.args.Length; i++)
                    args[i] = obj.args[i];
            }
        }
         

        
        public Cube_command_reqObj(Cube_command_reqObj obj, int col_p, int row_p)
        {
            this.ident = obj.ident;
            this.mCol = col_p;
            this.mRow = row_p;
            this.cmdType = obj.cmdType;
            this.requester_guy = obj.requester_guy;
            this.rpcPollId = obj.rpcPollId;
            this.guiVal = obj.guiVal;
            this.args = obj.args;
            this.ReturnBox = obj.ReturnBox;


        }
        public Cube_command_reqObj(int ident_p, int col_p, int row_p, commandType commd, /*params*/ string[] arg_p)
        {
            cmdType = commd;
            ident = ident_p;
            args = arg_p;
            mRow = row_p;
            mCol = col_p;

            /*
            args = new string[arg_p.Length];

            for (int i = 0; i < arg_p.Length; i++)
            {
                arg_p[i] = arg_p[i];
            
            }
             * */

        }

        public Cube_command_reqObj(cmd_requster requester,int ident_p, int col_p, int row_p, commandType commd, /*params*/ string[] arg_p, TextBox Result_p, GuiBoxArray gui_p)
        {
            cmdType = commd;
            ident = ident_p;
            args = arg_p;
            mRow = row_p;
            mCol = col_p;
            guiVal = gui_p;
            ReturnBox = Result_p;
            requester_guy = requester;

            /*
            args = new string[arg_p.Length];

            for (int i = 0; i < arg_p.Length; i++)
            {
                arg_p[i] = arg_p[i];
            
            }
             * */

        }
        public Cube_command_reqObj(cmd_requster requester, int col_p, int row_p, commandType commd, /*params*/ string[] arg_p, TextBox Result_p, GuiBoxArray gui_p)
        {
            cmdType = commd;
           
            args = arg_p;
            mRow = row_p;
            mCol = col_p;
            guiVal = gui_p;
            ReturnBox = Result_p;
            requester_guy = requester;

            /*
            args = new string[arg_p.Length];

            for (int i = 0; i < arg_p.Length; i++)
            {
                arg_p[i] = arg_p[i];
            
            }
             * */

        }

    }

    public class command_requestObj
    {
        public commandType cmdType = commandType.cmd_none;
        public System.Windows.Forms.TextBox txtBox = null;
        public System.Windows.Forms.TrackBar Slider = null;
        public DateTime time = DateTime.Now;
        public GuiBoxArray guiVal = null;
        public Int32 MsgCount = 0;
        public Int32 linenum = 0;
        //public List<System.Windows.Forms.TextBox> ResultVal = new List<System.Windows.Forms.TextBox>();

        public command_requestObj(commandType commd,System.Windows.Forms.TextBox txt,System.Windows.Forms.TrackBar slder)
        {
            cmdType = commd;
            txtBox = txt;
            Slider = slder;
        }

        public command_requestObj(commandType commd, System.Windows.Forms.TextBox txt, System.Windows.Forms.TrackBar slder, GuiBoxArray resultGui)
        {
            cmdType = commd;
            txtBox = txt;
            Slider = slder;
            guiVal = resultGui;
        }

        public command_requestObj(commandType commd, System.Windows.Forms.TextBox txt,GuiBoxArray resultGui)
        {

            guiVal = resultGui;
            cmdType = commd;
            txtBox = txt;
        }

        public command_requestObj(commandType commd, System.Windows.Forms.TextBox txt)
        {

            cmdType = commd;
            txtBox = txt;
        }

        public command_requestObj(commandType commd, System.Windows.Forms.TrackBar slder)
        {
            cmdType = commd;
            Slider = slder;
        }

    }

    public class Ssh_command
    {
        public Ssh_command(string cmd, Button but)
        {
            command = cmd;
            Button_P = but;
        }

        public Ssh_command(string cmd, Button but, string remot)
        {
            command = cmd;
            Button_P = but;
            remoteFile = remot;
        }

        public string sshCmd
        {
            get
            {
                return command;
            }

        }

        public string sshRemote
        {
            get
            {
                return remoteFile;
            }

        }

        public bool butStatus
        {
            get
            {
                return Button_P.Enabled;
            }
            set
            {
                Button_P.Enabled = value;
            }

        }



        private string command = string.Empty;
        private Button Button_P = null;
        private string remoteFile = string.Empty;
    }


    
}
